// RecordsetPtrWrap.cpp: implementation of the RecordsetPtrWrap class.
//
//////////////////////////////////////////////////////////////////////

#include "StdAfx.h"
#include "RecordsetPtrWrap.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace DAWrapper
{
RecordsetPtrWrap::RecordsetPtrWrap()
{
	m_RS.CreateInstance( __uuidof( Recordset ) );
}

RecordsetPtrWrap::~RecordsetPtrWrap()
{
	if ( m_RS )
	{
		Close();
		m_RS.Release();
	}
}

HRESULT RecordsetPtrWrap::Set( const CString& queryStatement, const _ConnectionPtr& connPtr )
{
	try
	{
		Close();
		HRESULT hr = m_RS->Open( (_variant_t)queryStatement, (IUnknown*)connPtr,
			adOpenStatic, adLockOptimistic, adCmdText );
		return hr;
	}
	catch( _com_error e )
	{
		ErrorAlert( e );
		return E_FAIL;
	}
}
}
